Using aliases

Use an Alias to get consistent access to a Kanzi node. You can use aliases to access nodes both in Kanzi Studio and using the Kanzi Engine API or scripting. Because while creating your application in Kanzi Studio you move nodes in the scene graph of your project, the easiest way to keep track of them is to use aliases. You can retrieve the alias target nodes with the API or scripting using the name of the alias, regardless of the node location in the project.

Note that you must always add aliases to the resource dictionary of the node from which you want to retrieve them.

Creating an alias from a node

When you create an alias from a node, Kanzi Studio adds that alias resource dictionary of the nearest ancestor of that node that contains a resource dictionary. For example, if a Scene has a resource dictionary and it contains a Camera, when you create an alias directly from the Camera node, Kanzi Studio automatically adds the alias pointing to the Camera node to the resource dictionary of the Scene node.

To create an alias:

  1. In the Project press Alt and right-click the node to which you want Kanzi Studio to automatically add the alias from the descendants of that node, and select Resource Dictionary.
    For example, if you want to use aliases to access the nodes inside the Scene node, add the Resource Dictionary to that Scene.
  2. In the Project press Alt and right-click a descendant node of the node that contains a resource dictionary, and select Alias.
    For example, in a Scene that contains a Camera, press Alt and right-click the Camera, and select Alias.
    Kanzi Studio creates an alias pointing to the node from which you created the alias and adds it to the resource dictionary of its nearest parent node that contains a resource dictionary.

Creating an alias and manually setting its target

To create an alias and manually set its target:

  1. If you do not have the Context Resources window open, select Window > Context Resources.
  2. In the Project press Alt and right-click the node to the resource dictionary of which you want to add an alias, and select Resource Dictionary.
    For example, if you want to use aliases to access the nodes inside the Scene node, add the Resource Dictionary to that Scene.
  3. In the Context Resources click Add resource to add an alias to the resource dictionary of the node selected in the Project and select Create New > Alias.
  4. In the Properties set:

Using aliases in bindings

Use bindings to update properties or property attributes of one node with the properties or property attributes of other nodes.

To use aliases in bindings, enter in curly braces the # sign followed by the alias name, followed by a forward slash and property name of the alias' target.

For example, to bind a property to the Layout Width property of the target node of the alias named Sphere in the Expression of the Binding Argument Editor enter

{#Sphere/LayoutWidth}

See Using bindings and Reference for bindings expressions.

Using an alias to set a target for an action

To use an alias to define a target item for an action:

  1. Create an alias. See Creating an alias from a node.
  2. Add a trigger to a node. See Using triggers.
  3. In the Properties click the Add drop-down menu select an action.
    For example, select Play Animation action.
  4. In the Message Editor set the Target Item property to the alias you created in the first step, and click Save.

Using Aliases in the API

To use aliases to access nodes using the API

// Get the reference to the Grid List Box 3D node using the alias #Grid List Box that is
// in the resource dictionary of the Scene node.
GridListBox3DSharedPtr gridListBox = scene->lookupNode<GridListBox3D>("#Grid List Box");

See also

Using local and global resources

Resource management

Using bindings

Reference for bindings expressions